/*
 * Copyright 2020 tu.cn All right reserved. This software is the
 * confidential and proprietary information of tu.cn ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Tu.cn
 */
package com.onedec.client.controller;

import com.onedec.admin.entity.OnedecEmp;
import com.onedec.client.entity.OnedecClient;
import com.onedec.client.service.ClientService;
import com.onedec.utils.PageBean;
import com.onedec.utils.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author 31014
 * @date 2020/7/15 18:34
 */
@RestController
@RequestMapping("client")
public class ClientController {
    @Resource
    private ClientService clientService;

    @PostMapping
    public ResponseEntity insertClient(OnedecClient onedecClient, String clientEmpId) {
        onedecClient.setClientBak1(Integer.parseInt(clientEmpId));
        clientService.insertClient(onedecClient);

        return ResponseEntity.SUCCESS;
    }

    @GetMapping("list")
    public ResponseEntity getClients(Integer page, Integer limit, OnedecClient onedecClient) {
        final PageBean<OnedecClient> pageBean = clientService.selectClients(page, limit, onedecClient);
        return new ResponseEntity(pageBean);
    }

}